/**
 * 
 */
package com.douyu.ocean.recom.platfrom.core.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.douyu.ocean.recom.platform.api.model.entiry.RecomRule;
import com.douyu.ocean.recom.platfrom.core.dal.mapper.RecomRuleMapper;
import com.douyu.ocean.recom.platfrom.core.service.RecomRuleService;

import tk.mybatis.mapper.entity.Example;

/**
 * @author leiruiqi
 *
 */
@Service("recomRuleService")
public class RecomRuleServiceImpl implements RecomRuleService{

	@Resource
	private RecomRuleMapper  recomRuleMapper;
	
	@Override
	public void save(RecomRule rocomRule) {
		recomRuleMapper.insertSelective(rocomRule);
	}

	@Override
	public List<RecomRule> queryAllByStatus(Integer status) {
		Example condition = new Example(RecomRule.class);
		condition.orderBy("id").asc();
		condition.createCriteria().andEqualTo("status", 0);
		return recomRuleMapper.selectByExample(condition);
	}

	@Override
	public boolean updateById(RecomRule record) {
		return 1==recomRuleMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public RecomRule getByCode(String code) {
		RecomRule record = new RecomRule();
		record.setCode(code);
		return recomRuleMapper.selectOne(record);
	}

	@Override
	public RecomRule getById(Long id) {
		RecomRule record = new RecomRule();
		record.setId(id);
		return recomRuleMapper.selectOne(record);
	}

}
